#ifndef __OLED_H
#define __OLED_H

#include "stm32f1xx_hal.h"

#include "stdlib.h"
#define OLED_MODE 0
#define SIZE 8
#define XLevelL 0x00
#define XLevelH 0x10
#define Max_Column 128
#define Max_Row 64
#define Brightness 0xFF
#define X_WIDTH 128
#define Y_WIDTH 64

// OLED控制命令
#define OLED_CMD 0x00
#define OLED_DATA 0x40
#define OLED_I2C_ADDRESS 0x78
/* OLED屏幕有7行 */
#define line1 0
#define line2 1
#define line3 2
#define line4 3
#define line5 4
#define line6 5
#define line7 6
#define line8 7
/* OLED屏幕有128的点,也就是16列（16*8） */
#define byte(data) data * 8
//-----------------OLED IIC端口定义----------------

//#define OLED_SCLK_Clr() GPIO_ResetBits(GPIOB, GPIO_Pin_6) // SCL
//#define OLED_SCLK_Set() GPIO_SetBits(GPIOB, GPIO_Pin_6)

//#define OLED_SDIN_Clr() GPIO_ResetBits(GPIOB, GPIO_Pin_7) // SDA
//#define OLED_SDIN_Set() GPIO_SetBits(GPIOB, GPIO_Pin_7)

//#define OLED_CMD 0  // 写命令
//#define OLED_DATA 1 // 写数据

// OLED控制用函数
void OLED_WR_Byte(unsigned dat, unsigned cmd);
void OLED_Display_On(void);
void OLED_Display_Off(void);
void OLED_Init(void);
void OLED_Clear(void);
void OLED_ClearBlue(void);
void OLED_ClearLine(uint8_t line);
void OLED_DrawPoint(uint8_t x, uint8_t y, uint8_t t);
void OLED_Fill(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t dot);
void OLED_ShowChar(uint8_t x, uint8_t y, uint8_t chr, uint8_t Char_Size);
void OLED_ShowNum(uint8_t x, uint8_t y, uint32_t num, uint8_t len, uint8_t size);
void OLED_ShowString(uint8_t x, uint8_t y, uint8_t *p, uint8_t Char_Size);
void OLED_Set_Pos(unsigned char x, unsigned char y);
void OLED_ShowCHinese(uint8_t x, uint8_t y, const char data[][16], uint8_t num);
void OLED_ShowCHinese7x7(uint8_t x, uint8_t y, const char data[][16], uint8_t num);
void OLED_ShowCHineseString(uint8_t x, uint8_t y, const char data[][16], uint8_t num);
void OLED_DrawBMP(unsigned char x0, unsigned char y0, unsigned char x1, unsigned char y1, unsigned char BMP[]);
void Delay_50ms(unsigned int Del_50ms);
void Delay_1ms(unsigned int Del_1ms);
void fill_picture(unsigned char fill_Data);
void Picture(void);
void IIC_Start(void);
void IIC_Stop(void);
void Write_IIC_Command(unsigned char IIC_Command);
void Write_IIC_Data(unsigned char IIC_Data);
void Write_IIC_Byte(unsigned char IIC_Byte);

void IIC_Wait_Ack(void);
#endif
